
import 'package:flutter/material.dart';
import 'package:txtest/cache.dart';

class NavigatorFilter extends NavigatorObserver{
  final passUrlArr = [
    "/loginPage"
  ];  
  @override
  void didPush(Route route, Route previousRoute) async{
    super.didPush(route, previousRoute);
    // TODO: implement didPush
    var userToken = await getUserToken();
    var isPassUrl = (route.settings.name == null || passUrlArr.contains(route.settings.name));
    if((userToken == null || userToken.isEmpty) && !isPassUrl){
      navigator.pushNamedAndRemoveUntil('/loginPage',(Route<dynamic> route) => false);
      return;
    }
  }
}